﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Ylh.Data
{
   public class ColumnOpera
    {

        public List<String> _propertyName = new List<string>();
        public List<String> PropertyName
        {
            get { return _propertyName; }
            set { _propertyName = value; }
        }

        public ColumnOpera(EntityBase e)
        {
            e.PropertyNameGetting += new EventHandler<PropertyNameGettingEventArgs>(PropertyNameGetting);
        }

        public void PropertyNameGetting(object sender, PropertyNameGettingEventArgs e)
        {
            PropertyName.Add(e.PropertyName);
        }
        public String[] CreateSelectColumn(params object[] Fields)
        {
            if (PropertyName.Count == 0) return new String[] { };

            return PropertyName.Distinct(new StrComparer()).ToArray();
        }
    }

    public class StrComparer : IEqualityComparer<String>
    {
        public bool Equals(String x, String y)
        {
            return x.ToUpper() == y.ToUpper();
        }

        public int GetHashCode(String obj)
        {
            return obj.ToUpper().GetHashCode();
        }
    }



}
